<%

Class clsEventos_list2 'Eventos_list2 Class @1-D55003CB

'Page Variables @1-792B1C11
    Dim Redirect
    Dim Tpl, HTMLTemplate
    Dim TemplateFileName
    Dim ComponentName
    Dim PathToCurrentPage
    Dim Attributes

    ' Events
    Dim CCSEvents
    Dim CCSEventResult

    ' Connections
    Dim DBConnection1

    ' Page controls
    Dim Eventos
    Dim ChildControls
    Public Visible
    Public Page
    Public Name
    Public CacheAction
    Private TemplatePathValue
'End Page Variables

'Page Class_Initialize Event @1-D0E56793
    Private Sub Class_Initialize()
        Visible = True
        Set Page = Me
        Set ParentPage = Me
        TemplatePathValue = ""
        Redirect = ""
        TemplateFileName = "Eventos_list2.html"
        Set CCSEvents = CreateObject("Scripting.Dictionary")
        PathToCurrentPage = "./"
    End Sub
'End Page Class_Initialize Event

'Page Class_Terminate Event @1-C6E18E69
    Private Sub Class_Terminate()
        CCSEventResult = CCRaiseEvent(CCSEvents, "BeforeUnload", Me)
        Set Page = Nothing
        If NOT Visible Then _
            Exit Sub
        If DBConnection1.State = adStateOpen Then _
            DBConnection1.Close
        Set DBConnection1 = Nothing
        Set CCSEvents = Nothing
        Set Eventos = Nothing
    End Sub
'End Page Class_Terminate Event

'Page BindEvents Method @1-D8FDB1E8
    Sub BindEvents()
        CCSEventResult = CCRaiseEvent(CCSEvents, "AfterInitialize", Me)
    End Sub
'End Page BindEvents Method

'Operations Method @1-E8B9371E
    Function Operations()
        If NOT Visible Then _ 
            Exit Function
        Operations = Redirect
    End Function
'End Operations Method

'Initialize Method @1-F297ECF2
    Sub Initialize(Name, Path)
    Me.Name = Name
        CCSEventResult = CCRaiseEvent(CCSEvents, "OnInitializeView", Me)
        If NOT Visible Then _
            Exit Sub
        Set DBConnection1 = New clsDBConnection1
        DBConnection1.Open

        ' Create Components
        Set Eventos = New clsGridEventos
        Set Eventos.Page = Me
        TemplatePathValue=path
        BindEvents
        Eventos.Initialize DBConnection1
        Set HTMLTemplate = new clsTemplate
        Set HTMLTemplate.Cache = TemplatesRepository
        HTMLTemplate.LoadTemplate TemplateFilePath & TemplatePathValue & TemplateFileName
        HTMLTemplate.SetVar "@CCS_PathToRoot", PathToRoot
        Set Tpl = HTMLTemplate.Block("main")
    End Sub
'End Initialize Method

'Page Show Method @1-7586160E
    Sub Show(MainTpl)
        CCSEventResult = CCRaiseEvent(CCSEvents, "BeforeShow", Me)
        If NOT Visible Then _
            Exit Sub
        Set ChildControls = CCCreateCollection(Tpl, Null, ccsParseOverwrite, _
            Array(Eventos))
        ChildControls.Show
        Attributes.Show HTMLTemplate, "page:"
        HTMLTemplate.Parse "main", False
        MainTpl.Variable(Name) = HTMLTemplate.GetVar("main")
    End Sub
'End Page Show Method

'Let TemplatePath Property @1-520E3E1A
    Property Let TemplatePath(NewTemplatePath)
        TemplatePathValue = NewTemplatePath
    End Property
'End Let TemplatePath Property

'Get TemplatePath Property @1-9428206A
    Property Get TemplatePath
        TemplatePath = TemplatePathValue
    End Property
'End Get TemplatePath Property

'TemplateURL Property @1-CFFB06B3
    Property Get TemplateURL
        TemplateURL = Replace(TemplatePathValue, "\", "/")
    End Property
'End TemplateURL Property

End Class 'End Eventos_list2 Class @1-A61BA892

Class clsGridEventos 'Eventos Class @2-7DD5388E

'Eventos Variables @2-C380E0E0

    ' Private variables
    Private VarPageSize
    ' Public variables
    Public ComponentName, CCSEvents
    Public Visible, Errors
    Public DataSource
    Public PageNumber
    Public Command
    Public TemplateBlock
    Public IsDSEmpty
    Public ForceIteration
    Public Attributes
    Private ShownRecords
    Public Page
    Public Recordset

    Private CCSEventResult

    ' Grid Controls
    Public StaticControls, RowControls
    Dim NomeEvento
    Dim Cidade
    Dim PaisDescricao
    Dim DataInicioEvento
    Dim DataFimEvento
    Dim Navigator
'End Eventos Variables

'Eventos Class_Initialize Event @2-9A14A2DE
    Private Sub Class_Initialize()
        ComponentName = "Eventos"
        Visible = True
        Set CCSEvents = CreateObject("Scripting.Dictionary")
        Set Attributes = New clsAttributes
        Set Errors = New clsErrors
        Set DataSource = New clsEventosDataSource
        Set Command = New clsCommand
        PageSize = CCGetParam(ComponentName & "PageSize", Empty)
        If IsNumeric(PageSize) And Len(PageSize) > 0 Then
            If PageSize <= 0 Then Errors.AddError(CCSLocales.GetText("CCS_GridPageSizeError", Empty))
            If PageSize > 100 Then PageSize = 100
        End If
        If NOT IsNumeric(PageSize) OR IsEmpty(PageSize) Then _
            PageSize = 20 _
        Else _
            PageSize = CInt(PageSize)
        PageNumber = CCGetParam(ComponentName & "Page", 1)
        If Not IsNumeric(PageNumber) And Len(PageNumber) > 0 Then
            Errors.AddError(CCSLocales.GetText("CCS_GridPageNumberError", Empty))
            PageNumber = 1
        ElseIf Len(PageNumber) > 0 Then
            If PageNumber > 0 Then
                PageNumber = CInt(PageNumber)
            Else
                Errors.AddError(CCSLocales.GetText("CCS_GridPageNumberError", Empty))
                PageNumber = 1
            End If
        Else
            PageNumber = 1
        End If

        Set NomeEvento = CCCreateControl(ccsLink, "NomeEvento", Empty, ccsText, Empty, CCGetRequestParam("NomeEvento", ccsGet))
        Set Cidade = CCCreateControl(ccsLabel, "Cidade", Empty, ccsText, Empty, CCGetRequestParam("Cidade", ccsGet))
        Set PaisDescricao = CCCreateControl(ccsLabel, "PaisDescricao", Empty, ccsText, Empty, CCGetRequestParam("PaisDescricao", ccsGet))
        Set DataInicioEvento = CCCreateControl(ccsLabel, "DataInicioEvento", Empty, ccsDate, Array("dd", "/", "mm", "/", "yyyy"), CCGetRequestParam("DataInicioEvento", ccsGet))
        Set DataFimEvento = CCCreateControl(ccsLabel, "DataFimEvento", Empty, ccsDate, Array("dd", "/", "mm", "/", "yyyy"), CCGetRequestParam("DataFimEvento", ccsGet))
        Set Navigator = CCCreateNavigator(ComponentName, "Navigator", FileName, 10, tpSimple)
    IsDSEmpty = True
    End Sub
'End Eventos Class_Initialize Event

'Eventos Initialize Method @2-57CE6952
    Sub Initialize(objConnection)
        If NOT Visible Then Exit Sub

        Set DataSource.Connection = objConnection
        DataSource.PageSize = PageSize
        DataSource.AbsolutePage = PageNumber
    End Sub
'End Eventos Initialize Method

'Eventos Class_Terminate Event @2-B97CC660
    Private Sub Class_Terminate()
        Set CCSEvents = Nothing
        Set DataSource = Nothing
        Set Command = Nothing
        Set Errors = Nothing
        Set Attributes = Nothing
    End Sub
'End Eventos Class_Terminate Event

'Eventos Show Method @2-513F5BB5
    Sub Show(Tpl)
        Dim HasNext
        If NOT Visible Then Exit Sub

        Dim RowBlock


        CCSEventResult = CCRaiseEvent(CCSEvents, "BeforeSelect", Me)
        Set Recordset = DataSource.Open(Command)
        If DataSource.Errors.Count = 0 Then IsDSEmpty = Recordset.EOF

        Set TemplateBlock = Tpl.Block("Grid " & ComponentName)
        If TemplateBlock is Nothing Then Exit Sub
        Set RowBlock = TemplateBlock.Block("Row")
        Set StaticControls = CCCreateCollection(TemplateBlock, Null, ccsParseOverwrite, _
            Array(Navigator))
            Navigator.SetDataSource Recordset
        Set RowControls = CCCreateCollection(RowBlock, Null, ccsParseAccumulate, _
            Array(NomeEvento, Cidade, PaisDescricao, DataInicioEvento, DataFimEvento))

        CCSEventResult = CCRaiseEvent(CCSEvents, "BeforeShow", Me)
        If NOT Visible Then Exit Sub

        RowControls.PreserveControlsVisible
        Errors.AddErrors DataSource.Errors
        If Errors.Count > 0 Then
            TemplateBlock.HTML = CCFormatError("Grid " & ComponentName, Errors)
        Else

            ' Show NoRecords block if no records are found
            If Recordset.EOF Then
                Attributes.Show TemplateBlock, "Eventos:"
                TemplateBlock.Block("NoRecords").Parse ccsParseOverwrite
            End If
            HasNext = HasNextRow()
            ForceIteration = False
            Do While ForceIteration Or HasNext
                If HasNext Then
                    NomeEvento.Value = Recordset.Fields("NomeEvento")
                    NomeEvento.Parameters = CCGetQueryString("QueryString", Array("ccsForm"))
                    NomeEvento.Parameters = CCAddParam(NomeEvento.Parameters, "IdEvento", Recordset.Fields("NomeEvento_param1"))
                    NomeEvento.Page = Page.TemplateURL & "Eventos_maint3.asp"
                    Cidade.Value = Recordset.Fields("Cidade")
                    PaisDescricao.Value = Recordset.Fields("PaisDescricao")
                    DataInicioEvento.Value = Recordset.Fields("DataInicioEvento")
                    DataFimEvento.Value = Recordset.Fields("DataFimEvento")
                End If
                CCSEventResult = CCRaiseEvent(CCSEvents, "BeforeShowRow", Me)
                Attributes.Show TemplateBlock.Block("Row"), "Eventos:"
                RowControls.Show
                If HasNext Then Recordset.MoveNext
                ShownRecords = ShownRecords + 1
                HasNext = HasNextRow()
            Loop
            Attributes.Show TemplateBlock, "Eventos:"
            StaticControls.Show
        End If

    End Sub
'End Eventos Show Method

'Eventos PageSize Property Let @2-54E46DD6
    Public Property Let PageSize(NewValue)
        VarPageSize = NewValue
        DataSource.PageSize = NewValue
    End Property
'End Eventos PageSize Property Let

'Eventos PageSize Property Get @2-9AA1D1E9
    Public Property Get PageSize()
        PageSize = VarPageSize
    End Property
'End Eventos PageSize Property Get

'Eventos RowNumber Property Get @2-F32EE2C6
    Public Property Get RowNumber()
        RowNumber = ShownRecords + 1
    End Property
'End Eventos RowNumber Property Get

'Eventos HasNextRow Function @2-9BECE27A
    Public Function HasNextRow()
        HasNextRow = NOT Recordset.EOF AND ShownRecords < PageSize
    End Function
'End Eventos HasNextRow Function

End Class 'End Eventos Class @2-A61BA892

Class clsEventosDataSource 'EventosDataSource Class @2-550438CF

'DataSource Variables @2-EFDDEDD8
    Public Errors, Connection, Parameters, CCSEvents

    Public Recordset
    Public SQL, CountSQL, Order, Where, Orders, StaticOrder
    Public PageSize
    Public PageCount
    Public AbsolutePage
    Public Fields
    Dim WhereParameters
    Public AllParamsSet
    Public CmdExecution
    Public InsertOmitIfEmpty
    Public UpdateOmitIfEmpty

    Private CurrentOperation
    Private CCSEventResult

    ' Datasource fields
    Public NomeEvento
    Public NomeEvento_param1
    Public Cidade
    Public PaisDescricao
    Public DataInicioEvento
    Public DataFimEvento
'End DataSource Variables

'DataSource Class_Initialize Event @2-983624C3
    Private Sub Class_Initialize()

        Set CCSEvents = CreateObject("Scripting.Dictionary")
        Set Fields = New clsFields
        Set Recordset = New clsDataSource
        Set Recordset.DataSource = Me
        Set Errors = New clsErrors
        Set Connection = Nothing
        AllParamsSet = True
        Set NomeEvento = CCCreateField("NomeEvento", "NomeEvento", ccsText, Empty, Recordset)
        Set NomeEvento_param1 = CCCreateField("NomeEvento_param1", "IdEvento", ccsText, Empty, Recordset)
        Set Cidade = CCCreateField("Cidade", "Cidade", ccsText, Empty, Recordset)
        Set PaisDescricao = CCCreateField("PaisDescricao", "PaisDescricao", ccsText, Empty, Recordset)
        Set DataInicioEvento = CCCreateField("DataInicioEvento", "DataInicioEvento", ccsDate, Array("yyyy", "-", "mm", "-", "dd", " ", "HH", ":", "nn", ":", "ss"), Recordset)
        Set DataFimEvento = CCCreateField("DataFimEvento", "DataFimEvento", ccsDate, Array("yyyy", "-", "mm", "-", "dd", " ", "HH", ":", "nn", ":", "ss"), Recordset)
        Fields.AddFields Array(NomeEvento, NomeEvento_param1, Cidade, PaisDescricao, DataInicioEvento, DataFimEvento)

        SQL = "SELECT TOP {SqlParam_endRecord} IdEvento, NomeEvento, Cidade, PaisDescricao, DataInicioEvento, DataFimEvento  " & vbLf & _
        "FROM Eventos INNER JOIN Paises ON " & vbLf & _
        "Eventos.Pais = Paises.IdPais {SQL_Where} {SQL_OrderBy}"
        CountSQL = "SELECT COUNT(*) " & vbLf & _
        "FROM Eventos"
        Where = "DataExibicao >= #" & Now() & "#" 
        Order = "DataInicioEvento"
        StaticOrder = ""
    End Sub
'End DataSource Class_Initialize Event

'BuildTableWhere Method @2-98E5A92F
    Public Sub BuildTableWhere()
    End Sub
'End BuildTableWhere Method

'Open Method @2-09F85DD8
    Function Open(Cmd)
        Errors.Clear
        If Connection Is Nothing Then
            Set Open = New clsEmptyDataSource
            Exit Function
        End If
        Set Cmd.Connection = Connection
        Cmd.CommandOperation = cmdOpen
        Cmd.PageSize = PageSize
        Cmd.ActivePage = AbsolutePage
        Cmd.CommandType = dsTable
        CCSEventResult = CCRaiseEvent(CCSEvents, "BeforeBuildSelect", Me)
        Cmd.SQL = SQL
        Cmd.CountSQL = CountSQL
        Cmd.Where = Where
        Cmd.OrderBy = Order
        If(Len(StaticOrder)>0) Then
            If Len(Order)>0 Then Cmd.OrderBy = ", "+Cmd.OrderBy
            Cmd.OrderBy = StaticOrder + Cmd.OrderBy
        End If
        Cmd.Options("CLAUSE") = " TOP {SqlParam_endRecord}"
        Cmd.Options("SYNTAX") = "Top"
        Cmd.Options("PLACE") = "beforeFrom"
        CCSEventResult = CCRaiseEvent(CCSEvents, "BeforeExecuteSelect", Me)
        If Errors.Count = 0 And CCSEventResult Then _
            Set Recordset = Cmd.Exec(Errors)
        CCSEventResult = CCRaiseEvent(CCSEvents, "AfterExecuteSelect", Me)
        Set Recordset.FieldsCollection = Fields
        Set Open = Recordset
    End Function
'End Open Method

'DataSource Class_Terminate Event @2-41B4B08D
    Private Sub Class_Terminate()
        If Recordset.State = adStateOpen Then _
            Recordset.Close
        Set Recordset = Nothing
        Set Parameters = Nothing
        Set Errors = Nothing
    End Sub
'End DataSource Class_Terminate Event

End Class 'End EventosDataSource Class @2-A61BA892


%>
